﻿using System.Text;
using System.Web.Http;
using System.Web.Http.Results;
using Newtonsoft.Json;

namespace ML.WebApi.Controllers
{
    /// <summary>
    /// 基类控制器
    /// </summary>
    public class BaseApiController : ApiController
    {
        protected override JsonResult<T> Json<T>(T content, JsonSerializerSettings serializerSettings, Encoding encoding)
        {
            //设置日期格式
            var jsonSerializerSettings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss" };
            //设置取消循环引用
            jsonSerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore;
            return new JsonResult<T>(content, jsonSerializerSettings, encoding, this);
        }
    }
}